<%@ page language="java" contentType="text/html;charset=UTF-8" pageEncoding="UTF-8"%>
<%@page import="java.sql.Connection"%>
<%@page import="com.yuxin.common.util.DBUtil"%>
<%@page import="java.util.List"%>
<%@page import="java.util.Map"%>
<%@page import="java.util.regex.Pattern"%>
<%@page import="java.util.regex.Matcher"%>
<%@page import="com.yuxin.core.TransactionManager"%>
<%
	Connection conn = null;
	int pay_records = 0;
	int shipping_records = 0;
	boolean shopSetting = false;
	try{
		conn = DBUtil.getConnection();
		Map<String,Object> user = (HashMap<String, Object>)request.getSession().getAttribute("user");
		String trade_id  = (String)user.get("SRC_ID");
		
		String sql = "select count(t.ID) from p_shop t where t.TRADE_ID = ?";	
		int record = DBUtil.count(conn, sql, trade_id);
		shopSetting = (record > 0);
		
		if(shopSetting) {
			sql = "select count(t.ID) from p_orders t where t.TRADE_ID = ? and t.STATUS = 1";
			pay_records = DBUtil.count(conn, sql, trade_id);
			
			
			sql = "select count(t.ID) from p_orders t where t.TRADE_ID = ? and t.STATUS = 2";
			shipping_records = DBUtil.count(conn, sql, trade_id);
		}
		
	} catch (Exception ex) {
		ex.printStackTrace();
	} finally {		
		DBUtil.close(conn);
	}
%>
<!DOCTYPE html>

<%@page import="java.util.HashMap"%><html>
<head>
    <%@ include file="/meta.jsp" %>
    <title>${site_title}</title>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8">
    <style type="text/css">
	<!--
		#prod_list td {text-align:center; vertical-align:middle;}
	-->
	</style>
</head>
<body>
<div class="zx-container" >
	<%@ include file="/trader/menu.jsp" %>
	<div class="span9 offset3">
		<%@ include file="/header_bg.jsp" %>
        <div class="row-fluid zx-bg-cont">
          	<div style="margin-top:20px; text-align:center;">            	            	            		         	
                 <%
            		if(!shopSetting) {
            	%>
            		 <div style="padding-left:200px; text-align:left;"><a href="${ctx}/trader/shopsetting.jsp"><strong>您还没设置店铺，请点击进入店铺设置.</strong></a></div>            		
            	<%
            		} else {
            	%>  
                	<div style="padding-left:200px; text-align:left; margin-bottom:20px;"><strong>等待发货的订单数：<%=shipping_records %></strong></div> 
	                 <div style="padding-left:200px; text-align:left; margin-bottom:20px;"><strong>等待买家付款的订单数：<%=pay_records %></strong></div>
                <%
					}
				%>
        	</div>
        </div>
		<%@ include file="/footer_bg.jsp" %>
	</div>
</div>
</body>
</html>